<template>
	<view class="box">
		<view class="topBg">
			<image src="/static/bg.png" class="topbgimg"></image>
			<!-- @click="auth" -->
			<view class="userInfoBox">
				<view class="headImg">
					<button type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar">
						<image mode="aspectFill" :src="avatarUrl"></image>
					</button>
				</view>
				<view class="nameBox">
					<!-- <input v-model="user.nickName" type="nickname"/> -->
					{{ user.nickName }}
				</view>
			</view>
		</view>
		<view class="rMainBox">
			<uni-list :border="false" class="myList">
				<uni-list-item :border="false" title="我的订单" showArrow clickable="true" @click="goBills">
					<template v-slot:header>
						<view class="slot-box">
							<image class="slot-image" src="/static/user_icon02.png" mode="widthFix"></image>
						</view>
					</template>
				</uni-list-item>
				<uni-list-item :border="false" title="我的发票" showArrow  clickable="true" @click="goMyInvoiceBill">
					<template v-slot:header>
						<view class="slot-box">
							<image class="slot-image" src="/static/user_icon04.png" mode="widthFix"></image>
						</view>
					</template>
				</uni-list-item>
				<uni-list-item :border="false" title="关于赛事助手" showArrow clickable="true" @click="goAboutUs">
					<template v-slot:header>
						<view class="slot-box">
							<image class="slot-image" src="/static/user_icon03.png" mode="widthFix"></image>
						</view>
					</template>
				</uni-list-item>
			</uni-list>
		</view>

	</view>
</template>

<script setup>
import * as api from '@/common/api.js';
import * as match from '@/common/match.js';
import { getWxUser, getWxUserPhone } from '@/common/login.js';
import { ref } from 'vue';
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
const vTypeImg = ref('/static/v1.png');
const card = ref({});
const reportData = ref({});
const user = ref({});
const userImg = ref('');
const avatarUrl = ref('');
const captchaPhonenumber = ref('');
const captcha = ref('');
const inputDialog = ref(null);
const start = ref(false);
const canSend = ref(true);
const app = getApp();
const isMaster = ref(false);

onShow(() => {
	if (app.globalData.isLogin) {
		init();
	} else {
		app.firstLoadCallback = () => {
			init();
		};
	}
});
function init() {
	const currUser = uni.getStorageSync('currUser');
	user.value = currUser;

	avatarUrl.value = user.value.avatar;
}

function goBack() {
	uni.navigateBack({});
}
function onChooseavatar(e) {
	// 上传头像
	match.uploadFile(e).then(data => {
		avatarUrl.value = data.data;
		match.updateAvatar({ avatarUrl: avatarUrl.value }).then(res => {
			uni.showToast({
				title: '头像保存成功',
				icon: 'none',
				duration: 2000
			});
			uni.setStorageSync('currUser', res.data);
		});
	});
}

function goBills() {
	let path = '/pages_hotel/hotel/myBills';
	uni.navigateTo({
		url: path
	});
}

function goMyInvoiceBill() {
	let path = '/pages_hotel/hotel/myInvoice';
	uni.navigateTo({
		url: path
	});
}
function goAboutUs(){
	let path = '/pages_hotel/hotel/aboutUs';
	uni.navigateTo({
		url: path
	});
}
function building() {
	uni.showToast({
		title: '暂未开放，敬请期待。',
		icon: 'none',
		duration: 2000
	});
}

</script>

<style scoped lang="scss">
.box {
	width: 100vw;
	overflow: hidden;
}
.rMainBox {
	box-sizing: border-box;
	padding: 20rpx 25rpx 0;
	margin: 25rpx;
}
.userInfoBox {
	height: 200rpx;
}
.nameBox {
	position: absolute;
	left: 180rpx;
	top: 70rpx;
	font-size: 30rpx;
}
.nameBox view {
	color: #7b7f83;
	font-size: 26rpx;
	margin-top: 10rpx;
}
.goback {
	position: absolute;
	color: #fff;
	top: 100rpx;
	left: 35rpx;
}
.forAdmin {
	padding: 25rpx;
	box-sizing: border-box;
}
.topBg {
}
.onlyCardBottom {
	position: relative;
	width: 660rpx;
	margin: auto;
	height: 90rpx;
	.bbg {
		height: 90rpx;
		width: 660rpx;
	}
	.cardBottom {
		width: 660rpx;
		background: transparent;
		height: 90rpx;
		text {
			font-size: 28rpx;
			color: #925921;
		}
		.renewBtn {
			background: #874f02;
			color: #fff;
		}
	}
}
.headImg {
	border-radius: 50%;
	position: relative;
	top: 50rpx;
	overflow: hidden;
	width: 100rpx;
	height: 100rpx;
	border: 4px solid #ffffff;
	background: #c4f9cb;
	left: 40rpx;
	button {
		display: block;
		padding: 0;
	}
	image {
		width: 100rpx;
		height: 100rpx;
		display: block;
	}
}

.slot-image {
	width: 50rpx;
	position: relative;
	top: -8rpx;
	height: 50rpx;
	margin-right: 30rpx;
}

.myList {
}
.funcBar {
	display: flex;
	background: #fff;
	width: 700rpx;
	height: 140rpx;
	justify-content: space-around;
}
.funcBar view {
	display: flex;
	align-items: center;
	font-size: 36rpx;
}
.funcBar image {
	width: 80rpx;
	height: 80rpx;
}
.topbgimg {
	width: 100vw;
	position: absolute;
	z-index: -1;
}
.reportItembox {
	overflow: hidden;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
}
.reportItem {
	background: #fff;
	border-radius: 15rpx;
	width: 340rpx;
	margin-top: 25rpx;
	.t {
		border-bottom: 1px solid #e5e5e5;
		height: 70rpx;
		line-height: 70rpx;
		color: #2b3133;
		font-size: 30rpx;
		padding-left: 36rpx;
	}
	.rbody {
		display: flex;
		padding: 36rpx;
		box-sizing: border-box;
		view {
			font-size: 26rpx;
			color: #888;
			width: 40%;
		}
		text {
			color: #00c176;
			font-weight: bold;
			font-size: 36rpx;
			display: block;
			margin-bottom: 20rpx;
		}
	}
}
.changephonepop {
	width: 100%;
}
.changephonepop view {
	width: 100%;
	margin: 0 0 30rpx;
}
.changephonepop view input {
	width: 100%;
	background: #f4f4f4;
	font-size: 30rpx;
	height: 80rpx;
	padding: 0 15rpx;
	box-sizing: border-box;
	line-height: 80rpx;
}
.changephonepop view.ffff {
	display: flex;
}
.changephonepop view button {
	font-size: 24rpx;
	margin-left: 10rpx;
	white-space: nowrap;
	width: 260rpx;
	line-height: 80rpx;
	background: linear-gradient(90deg, #00c176, #3ed89b);
	color: #fff;
	padding: 0;
	border: none;
}
</style>
